<?
session_start();
define('CAPTCHA_SESSION_KEY', 'G0TCHA_CAPTCHA');

function checkCaptchaCode($code=null){
	return (isset($_SESSION[CAPTCHA_SESSION_KEY]) && (strcasecmp($code, $_SESSION[CAPTCHA_SESSION_KEY])==0));
}

header('Content-Type: text/xml'); 
echo "<?xml version=\"1.0\"?>\n";
echo "<reponse>\n";

if(isset($_POST['code'])){
$text = isset($_SESSION[CAPTCHA_SESSION_KEY])? $_SESSION[CAPTCHA_SESSION_KEY] : NULL;
	if(!$p =trim($_POST['code'])){
		echo '<res>404</res><valeur>ERREUR - Aucun code saisi !</valeur>\n';
	}
	else if(!checkCaptchaCode($p)){
		echo '<res>403</res><valeur>ERREUR - Le code saisi invalide !</valeur>\n' ;
	}
	else{
		echo '<res>200</res><valeur>OK</valeur>\n';
	}
}
echo "</reponse>\n";
?>